import service from "@/request";
import { groupExport, groupQuery, resGroupInt } from "./type";
import { queryInt, resInt } from "../type";

/**
 * 获取部门接口
 */
export const getGroupApi = (data: groupQuery) => {
  return service<any, resInt<queryInt<resGroupInt[]>>>({
    url: "/group",
    method: "get",
    params: data,
  });
};

/**
 * 导出表格
 * @param data 
 * @returns 
 */
export const exportGroupApi=(data: groupExport)=>{
    return service<resInt<object>>({
      url: "/group",
      method: "get",
      responseType: "blob",
      params: data,
    })
  }

/**
 * 删除部门
 * @param id
 * @returns
 */
export const delGroupApi = (id: number) =>
  service.delete<any, resInt<string>>(`/group/${id}`);

/**
 * 添加部门
 * @param data
 * @returns
 */
export const addGroupApi = (data: { name: string }) =>
  service.post<any, resInt<string>>("/group", data);

/**
 * 修改部门
 * @param data
 * @returns
 */
export const editGroupApi = (data: { id: number; name: string }) => {
  return service<any, resInt<object>>({
    url: "/group",
    method: "put",
    data,
  });
};
